/**
 * sysSafeOptionsServiceImpl
 * 项目名称:分秒金融
 *
 * @author lunli
 *
 * 功能描述:安全设置管理
 * 
 * 历史版本:2017-03-27 v1.0.0 lunli  创建:
 * 
 */
package com.fmjr.sys.sysSafeOptions.service.impl;

import com.fmjr.common.base.exception.BusinessException;
import com.fmjr.common.base.util.Pager;
import com.fmjr.common.util.SqlUtil;
import com.fmjr.sys.sysSafeOptions.bean.SysSafeOptions;
import com.fmjr.sys.sysSafeOptions.dao.SysSafeOptionsDao;
import com.fmjr.sys.sysSafeOptions.service.ISysSafeOptionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


@Service("sysSafeOptionsService")
public class  SysSafeOptionsServiceImpl implements ISysSafeOptionsService {
	

	@Autowired
    private SysSafeOptionsDao sysSafeOptionsDao;

	/**
	 * 根据条件查询安全设置记录
	 * @author lunli
	 * @param  pager
	 * @return SysSafeOptionsList
	 * @throws BusinessException
	 */
	public void selectSysSafeOptionsList(Pager<SysSafeOptions> pager) throws BusinessException{
		int totalCount = sysSafeOptionsDao.selectSysSafeOptionsCount(pager);
		int numPerPage = SqlUtil.checkPageSize(pager.getNumPerPage());
		int currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, pager.getPageNum());
		pager.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage));
		pager.setPageSize(numPerPage);
		pager.setCurrentPage(currentPage);
		pager.setTotalCount(totalCount);
		pager.setTotalPage(totalCount%numPerPage==0?totalCount/numPerPage:totalCount/numPerPage+1);
		List<SysSafeOptions> list = sysSafeOptionsDao.selectSysSafeOptionsList(pager);
		pager.setList(list);
	}
	
	/**
	 * 根据ID查询安全设置记录
	 * @author lunli
	 * @param id
	 * @return domain
	 * @throws BusinessException
	 */
	public SysSafeOptions selectSysSafeOptionsById(Long id) throws BusinessException{
		return sysSafeOptionsDao.selectSysSafeOptionsById(id);
	}

	/**
	 *  删除安全设置记录
	 * @author lunli	 
	 * @param id
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int deleteSysSafeOptionsById(Long id) throws BusinessException{
		return sysSafeOptionsDao.deleteSysSafeOptionsById(id);
	}
	
	/**
	 * 修改安全设置记录
	 * @author lunli
	 * @param sysSafeOptions
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int updateSysSafeOptions(SysSafeOptions sysSafeOptions) throws BusinessException{
		sysSafeOptions.setUpdateDate(new Date());
		return sysSafeOptionsDao.updateSysSafeOptionsSelective(sysSafeOptions);
	}

	/**
	 * 新增安全设置记录
	 * @author lunli
	 * @param sysSafeOptions
	 * @return
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int createSysSafeOptions(SysSafeOptions sysSafeOptions) throws BusinessException{
		sysSafeOptions.setCreateDate(new Date());
		return sysSafeOptionsDao.createSysSafeOptions(sysSafeOptions);
	}

	@Override
	public List<SysSafeOptions> selectSysSafeOptionsAll() {
		return sysSafeOptionsDao.selectSysSafeOptionsAll();
	}
	

	

}
